jQuery(function($){
	$('#navbarspan').html('多渠道订单&gt;订单信息');
	var item={
			grid : null,
			init:function(){
				this.state=[
							{value:0,text:"未出库"},
							{value:1,text:"已生成出库单"},
							{value:2,text:"已出库"}
						   ];
				var flag=$("#flag").val();
				var url="channelOrderItemPageList.do";
				var parms=[
							{name: "channelOrderId", value:$("#channelOrderId").val()}
		                    ];
				var columns=[
					            { display: '订单编号', name: 'channelOrderId',width:'80'},
					            { display: '货品编号', name: 'itemNum'},
					            { display: '商品名称', name: 'skuName',width:'500'},
					            { display: '商品价格(元)', name: 'itemPrice',width:'80'},
					            { display: '商品数量', name: 'itemTotal',width:'80'}
				            ];
				/*var prodPackageNo=$("#prodPackageNo").val();
				if(!prodPackageNo){
					if(flag){
						flag=1;
					}
				}*/
				if(flag==1){
					$('#navbarspan').html('商品包裹单&gt;包裹信息');
					url="productPackageItemPageList.do";
					columns=[
					            { display: '包裹单编号', name: 'prodPackageNo',width:'80'},
					            { display: '商品编号', name: 'commoNo'},
					            { display: '货品编号', name: 'prodNo'},
					           // { display: '货品条码', name: 'prodBarCode'},
					            { display: '商品名称', name: 'prodName',width:'300'},
					            { display: '规格', name: 'specName'},
					            { display: '供应商', name: 'supName'},
					            { display: '商品价格(元)', name: 'price',width:'80'},
					            { display: '商品数量', name: 'total',width:'80'},
					            { display: '出库状态', name: 'state', 
						              render: function (rowData, rowindex, value){
						            	    return item.getTextByValue(item.state,value);
						        }},
					            { display: '仓库', name: 'whName',width:'80'}
				            ];
					parms=[
							{name: "prodPackageNo", value:$("#prodPackageNo").val()}
		                  ]
				}
				if(flag==2){
					
					url="returnOrderItemPageList.do";
					columns=[
					            { display: '订单编号', name: 'channelOrderId',width:'80'},
					            { display: '商品编号', name: 'commoNo'},
					            { display: '货品编号', name: 'prodNo'},
					           // { display: '货品条码', name: 'prodBarCode'},
					            { display: '商品名称', name: 'prodName',width:'300'},
					            { display: '规则', name: 'specName'},
					            { display: '供应商', name: 'supName'},
					            { display: '商品价格(元)', name: 'price',width:'80'},
					            { display: '商品数量', name: 'total',width:'80'},
					            { display: '仓库', name: 'whName',width:'80'}
				            ];
					parms=[
							{name: "channelOrderId", value:$("#channelOrderId").val()}
		                  ]
				}
				var config={};
				config.url=url;
				config.columns=columns;
				config.parms=parms;
				this.pageList(config);
			},
			pageList:function(config){
				item.grid = $("#maingrid").ligerGrid({
		            columns: config.columns, 
		            pageSize:30,
		            width: '100%',
		            height: '94%',
		            dataType: 'server', 
		            dataAction: 'server',
		            pagesizeParmName: 'pageSize',
		            parms:config.parms ,
					url: config.url,
					toolbar: toolbar
		        });
				grid=item.grid;
			},
			setSelectBox:function(config){
				$.ajax({
					url:basePath+config.url,
					type:"post",
					dataType:"json",
					success:function(result){
						if(result  && result.length){
							config.dom.html('<option value="">请选择</option>');
							for(var x in result){
								config.dom.append('<option value="'+result[x][config.value]+'">'+result[x][config.text]+'</option>');
							}
						}
					}
				});
			},
			getTextByValue:function(objs,value){
				if(objs && objs.length){
					for(var x in objs){
						if(objs[x].value==value){
							return objs[x].text;
						}
					}
				}
			}
	};
	item.init();
}); 